<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - CheckBox Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset/reset-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<p class='demoTitle'>inputEx - CheckBox Usage</p>


<!-- Example 1 -->
<div class='exampleDiv'>

	<p class="title">Basic CheckBox creation</p>
	
	<p>Use the following code to create a basic inputEx CheckBox.</p>

	<div class='demoContainer' id='container1'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
			new inputEx.CheckBox({parentEl: 'container1'});
		</textarea>
			</div>

</div>


<!-- Example 2 -->
<div class='exampleDiv'>

	<p class="title">With a label</p>
	
	<p>Add the label</p>

	<div class='demoContainer' id='container2'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
			new inputEx.CheckBox({label: 'Do you like inputEx ?', rightLabel: 'Check me !', parentEl: 'container2', value: false});
		</textarea>
			</div>

</div>




<!-- Example 3 -->
<div class='exampleDiv'>

	<p class="title">Default returned values</p>
	
	<p>In its simplest form, the CheckBox returns <i>true</i> if checked, <i>false</i> otherwise.</p>

	<div class='demoContainer' id='container3'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
			var exampleDiv = YAHOO.util.Dom.get('container3');
			var field1 = new inputEx.CheckBox({rightLabel: 'I return true/false', parentEl: exampleDiv});
			var button = inputEx.cn('button', null, null, 'getValue()');
			exampleDiv.appendChild(button); 
			YAHOO.util.Event.addListener(button, 'click', function() { alert(field1.getValue()); });
		</textarea>
			</div>

</div>


<!-- Example 4 -->
<div class='exampleDiv'>

	<p class="title">Changing the returned values</p>
	
	<p>You can return different values if needed.</p>

	<div class='demoContainer' id='container4'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
			var exampleDiv = YAHOO.util.Dom.get('container4');
			var field2 = new inputEx.CheckBox({sentValues: ['Yes', 'No'], rightLabel: 'Do you agree ?', parentEl: exampleDiv, value: 'No'});
			var button = inputEx.cn('button', null, null, 'getValue()');
			exampleDiv.appendChild(button); 
			YAHOO.util.Event.addListener(button, 'click', function() { alert(field2.getValue()); });
		</textarea>
			</div>

</div>



<!-- Example 5 -->
<div class='exampleDiv'>

	<p class="title">Updated event</p>
	
	<p>How to listen to the updated event :</p>

	<div class='demoContainer' id='container5'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript" cols="60" rows="1">
			var el = YAHOO.util.Dom.get('container5');
			var field = new YAHOO.inputEx.CheckBox({parentEl: el });
			var logDiv = YAHOO.inputEx.cn('div', null, null, "Log :<br />");
			el.appendChild(logDiv);
			field.updatedEvt.subscribe(function() {
				logDiv.innerHTML += "Updated at "+(new Date())+"<br />";
			});
		</textarea>
			</div>

</div>



<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/yahoo/yahoo-min.js"></script> 
<script type="text/javascript" src="../lib/yui/dom/dom-min.js"></script> 
<script type="text/javascript" src="../lib/yui/event/event-min.js"></script>

<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/fields/CheckBox.js"  type='text/javascript'></script>

<script>

YAHOO.util.Event.addListener(window, 'load', function() {

	// Example 1
	new YAHOO.inputEx.CheckBox({parentEl: 'container1'});
	
	
	// Example 2
	new inputEx.CheckBox({label: 'Do you like inputEx ?', rightLabel: 'Check me !', parentEl: 'container2', value: false, description: 'Check this box if you like the inputEx demos'});
	
	
	// Example 3
	var exampleDiv = YAHOO.util.Dom.get('container3');
	var field1 = new YAHOO.inputEx.CheckBox({rightLabel: 'I return true/false', parentEl: exampleDiv});
	var button = YAHOO.inputEx.cn('button', null, null, 'getValue()');
	exampleDiv.appendChild(button); 
	YAHOO.util.Event.addListener(button, 'click', function() { alert(field1.getValue()); });
	
	
	// Example 4
	var exampleDiv = YAHOO.util.Dom.get('container4');
	var field2 = new YAHOO.inputEx.CheckBox({sentValues: ['Yes', 'No'], rightLabel: 'Do you agree ?', parentEl: exampleDiv, value: 'No'});
	var button = YAHOO.inputEx.cn('button', null, null, 'getValue()');
	exampleDiv.appendChild(button); 
	YAHOO.util.Event.addListener(button, 'click', function() { alert(field2.getValue()); });
	
	
	// Example 5
	var el = YAHOO.util.Dom.get('container5');
	var field = new YAHOO.inputEx.CheckBox({parentEl: el });
	
	var button1 = YAHOO.inputEx.cn('button', null, null, "SetValue with true");
	var bool = true;
	el.appendChild(button1);
	YAHOO.util.Event.addListener(button1, "click" ,function() {
	   field.setValue(bool);
	   bool = !bool;
	   button1.innerHTML = "SetValue with "+bool;
	});
	
	var logDiv = YAHOO.inputEx.cn('div', null, null, "Log :<br />");
	el.appendChild(logDiv);
	field.updatedEvt.subscribe(function(e,params) {
		var val = params[0];
		logDiv.innerHTML += "Updated at "+(new Date())+" with value: "+val+"<br />";
	});
	
	
});

</script>

<script src="js/dpSyntaxHighlighter.js"></script>
<script language="javascript"> 
dp.SyntaxHighlighter.HighlightAll('code');
</script>

 </body>
</html>